<template>
	<div>
		<a-modal v-model="show" title="添加组织" @ok="submit" @cancel="show = false">
			<a-form :label-col="{ span: 5 }" :wrapper-col="{ span: 19 }">
				<a-form-item label="计划名称">
					<a-input v-model="form.taskName" />
				</a-form-item>
				<a-form-item label="检查类型">
					<a-radio-group v-model="form.checkType">
						<a-radio :value="1">
							一般检查
						</a-radio>
					</a-radio-group>
				</a-form-item>
				<a-form-item label="检查方式">
					<a-radio-group v-model="form.checkWay">
						<a-radio :value="0">
							表格
						</a-radio>
						<a-radio :value="1">
							直接输入
						</a-radio>
					</a-radio-group>
				</a-form-item>
				<a-form-item label="组织">
					<a-select v-model="form.orgId">
						<a-select-option v-for="v in orgDatas" :key="v.orgId">{{v.orgName}}</a-select-option>
					</a-select>
				</a-form-item>
				<a-form-item label="开始时间">
					<a-date-picker v-model="form.startTime" format="YYYY-MM-DD" @change="startChange" />
				</a-form-item>
				<a-form-item label="结束时间">
					<a-date-picker v-model="form.endTime" format="YYYY-MM-DD" @change="endChange" />
				</a-form-item>
				<a-form-item label="备注">
					<a-textarea v-model="form.remark" />
				</a-form-item>
			</a-form>
		</a-modal>
	</div>
</template>
<script>
	import moment from "moment"
	// import { message } from 'ant-design-vue';
	import { orgLists } from "@/services/v2"
	export default {
		props: {

		},
		data() {
			return {
				// 是否显示弹框
				show: false,
				orgDatas: [],//组织列表
				form: {
					taskName: '',
					startTime: '',
					endTime: '',
					checkType: 0,
					checkWay: '',
					remark: '',
					orgId: '',
				},
			}
		},
		methods: {

			//打开弹窗,初始化
			open() {
				let self = this;
				//显示组件
				self.show = true;
				//获取组织
				self.getOrgLists();
			},

			endChange: function () {
				let self = this;
				self.form.endTime = moment(self.form.endTime).format("YYYY-MM-DD");
				return false;
			},

			startChange: function () {
				let self = this;
				self.form.startTime = moment(self.form.endTime).format("YYYY-MM-DD");
				return false;
			},

			//获取组织
			getOrgLists: function () {
				let self = this;
				orgLists().then((ref) => {
					ref.data.forEach(function (v) {
						self.orgDatas.push(v);
					});
				});
				return false;
			},

			//编辑提交
			submit: function () {
				let self = this;
				console.log(self.form, 111111111);
				return false;
			}
		},
	}
</script>